Cast big endian byte shuffling to uint#15988
Conversation
This works, but UBSan running on a big endian platform (in this, ppc64) will complain that the ((uchar*)buffer)[n] is int, and shifting that could be weird. Since the value of PHAR_GET_32 et al are almost always unsigned, it makes sense to cast these as unsigned. Fixes phar tests on a big endian system with UBSan enabled.
|
Wondering if it might be a good idea to centralize endianness mangling code in general; I saw ( |
|
Hmm, there is something wrong with the labeler; this PR is not supposed to be marked as ABI break; after all, ext/phar/phar.c is not a header (and phar doesn't publish any headers at all). Would someone know what's going on there? |
Yes, that seems to be a very good idea. Relevant parts could be made available as APIs for extensions, too. |
cmb69
left a comment
There was a problem hiding this comment.
This change looks good to me (but having a function like php_ifd_get32u() would be better).
@NattyNarwhal Consider using https://github.com/projg2/portable-endianness which we maintain for exactly this (just copy it). |
This works, but UBSan running on a big endian platform (in this, ppc64) will complain that the ((uchar*)buffer)[n] is int, and shifting that could be weird. Since the value of what PHAR_GET_32 et al usually set are almost always unsigned, it makes sense to cast these as unsigned.
Fixes phar tests on a big endian system with UBSan enabled.